<html lang="en" class="h-100">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>DRMS Login</title>
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="./images/favicon.png">
    <link href="./css/style.css" rel="stylesheet">

</head>

<body class="h-100">
<div class="authincation h-100">
    <div class="container h-100">
        <div class="row justify-content-center h-100 align-items-center">
            <div class="col-md-6">
                <div class="authincation-content">
                    <div class="row no-gutters">
                        <div class="col-xl-12">
                            <div class="auth-form">
                                <h4 class="text-center mb-4">登录</h4>
                                <form action="/DRMS/LoginServlet" method="post">
                                    <div class="form-group">
                                        <label class="mb-1"><strong>账号</strong></label>
                                        <input type="text" class="form-control" name="uid">
                                    </div>
                                    <div class="form-group">
                                        <label class="mb-1"><strong>密码</strong></label>
                                        <input type="password" class="form-control" id="pwd">
                                        <input type="hidden" name="pwdHash" id="pwdHash">
                                        <input type="hidden" name="mac" id="mac">
                                    </div>
                                    <div class="form-row d-flex justify-content-between mt-4 mb-2">
                                        <div class="form-group">
                                            <div class="custom-control custom-checkbox ml-1">
                                                <input type="checkbox" class="custom-control-input" id="basic_checkbox_1">
                                                <label class="custom-control-label" for="basic_checkbox_1">记住密码</label>
                                            </div>
                                        </div>
                                        <!-- <div class="form-group">
                                            <a href="page-forgot-password.html">Forgot Password?</a>
                                        </div> -->
                                    </div>
                                    <div class="text-center">
                                        <input type="submit" class="btn btn-primary btn-block" value="登录" onclick="sha()"></input>
                                    </div>
                                </form>
                                <div class="new-account mt-3">
                                    <p>没有账号？ <a class="text-primary" href="register.html">注册</a></p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--**********************************
    Scripts
***********************************-->
<!-- Required vendors -->
<script src="./vendor/global/global.min.js"></script>
<script src="./vendor/bootstrap-select/dist/js/bootstrap-select.min.js"></script>
<script src="./js/custom.min.js"></script>
<script src="./js/deznav-init.js"></script>
<script src="./crypto-js-4.0.0/crypto-js.js"></script>
</body>
<script>
    // 获取mac信息
    var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
    var service = locator.ConnectServer(".");
    document.getElementById("mac").value = macinfo();

    // 加密
    function sha(){
        document.getElementById("pwdHash").value = CryptoJS.SHA256(document.getElementById("pwd").value);
    }

    function macinfo(){
        var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE");
        var e = new Enumerator (properties);
        var info = "--";
        var i = 1;
        for (;!e.atEnd();e.moveNext ()){
            var p = e.item ();
            info += p.MACAddress + "--";
            i++;
        }
        return info;
    }
</script>

</html>